#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

char map[105][105];
int main()
{
	int x, y;
	scanf("%d%d", &x, &y);
	for (int i = 1; i <= x; i++)
		scanf("%s", map[i] + 1);
	for (int i = 1; i <= x; i++) {
		for (int j = 1; j <= y; j++) {
			int count = 0;
			if (map[i][j] == '*')continue;
			if (map[i + 1][j] == '*')count++;
			if (map[i - 1][j] == '*')count++;
			if (map[i][j + 1] == '*')count++;
			if (map[i][j - 1] == '*')count++;
			if (map[i + 1][j + 1] == '*')count++;
			if (map[i + 1][j - 1] == '*')count++;
			if (map[i - 1][j + 1] == '*')count++;
			if (map[i - 1][j - 1] == '*')count++;
			map[i][j] = count + '0';
		}
	}
	for (int i = 1; i <= x; i++) {
		for (int j = 1; j <= y; j++) {
			if (map[i][j] == '*')printf("%c", map[i][j]);
			else printf("%d", map[i][j] - '0');
		}
		printf("\n");
	}
		
	return 0;
}